<extend name="Base/common"/>

<block name="header">
  <header class="bar bar-nav">
    <a href="javascript:window.history.back(-1);" class="pull-left icon icon-arrow-left" style="left:-5px;"></a>
    <a href="{:U('Shops/detail', array('uid' => $data['uid']))}" class="pull-left shop-logo">
      <notempty name="data.logo">
        <img src="{:SITE_URL}{:get_image_thumb($data['logo'], 200, 200)}" alt="">
        <else />
        <img src="__IMG__/avatar-default.png" alt="">
      </notempty>
    </a>
    <php>if(is_weixin()){</php>
      <a href="javascript:$.ui.share.init();" class="pull-right icon icon-forward"></a>
    
    <php>}elseif(is_app()){</php>  
      <a href="javascript:;" id="appShare" data-uid="{$uid}" class="pull-right icon icon-forward"></a>
    <php>}else{</php>
    <php>}</php>
    <h1 class="title"><notempty name="meta_title">{$meta_title|get_short=12}<else/>{:C('WEB_SITE_TITLE')}</notempty></h1>
  </header>
</block>

<block name="body">
  <!-- 店铺幻灯 -->
  {:hook('advertise', array('where' => 'tid = 4 AND status = 1', 'num' => 8, 'tpl' => 'theme2'))}
  <div class="shop">
      <div class="list-filter sort">
          <!-- 排序 -->
          <dl class="dl-horizontal">
              <dd class="clearfix">
                  <a href="{:U('Shops/detail', array('cid' => $cid, 'uid'=>$uid, 'label' => $label, 'keyword' => $keyword, '_field' => 'is_top', '_order' => 'desc'))}" class="{$order_css['active']['is_top']['desc']}">推荐</a>
                  <a href="{:U('Shops/detail', array('cid' => $cid, 'uid'=>$uid, 'label' => $label, 'keyword' => $keyword, '_field' => 'viewnum', '_order' => 'desc'))}" class="{$order_css['active']['viewnum']['desc']}">人气</a>
                  <a href="{:U('Shops/detail', array('cid' => $cid, 'uid'=>$uid, 'label' => $label, 'keyword' => $keyword, '_field' => 'create_time', '_order' => 'desc'))}" class="{$order_css['active']['create_time']['desc']}">新品</a>
                  <if condition="$order_css['active']['price']['desc'] eq 'active'">
                      <a href="{:U('Shops/detail', array('cid' => $cid, 'uid'=>$uid, 'label' => $label, 'keyword' => $keyword, '_field' => 'price', '_order' => 'asc'))}" class="{$order_css['active']['price']['desc']}">价格<i class="icon icon-arrow-top"></i></a>
                      <else/>
                      <a href="{:U('Shops/detail', array('cid' => $cid, 'uid'=>$uid, 'label' => $label, 'keyword' => $keyword, '_field' => 'price', '_order' => 'desc'))}" class="{$order_css['active']['price']['asc']}">价格<i class="icon icon-arrow-bottom"></i></a>
                  </if>
                  <a href="{:U('Shops/detail', array('cid' => $cid, 'uid'=>$uid, 'label' => $label, 'keyword' => $keyword, '_field' => 'buynum', '_order' => 'desc'))}" class="{$order_css['active']['buynum']['desc']}">销量</a>
              </dd>
          </dl>
      </div>
    <!-- 店铺商品列表 -->
    <div class="content-padded">
      <h4>精选优品
        <if condition="$data['uid'] eq UID">
          <small class="pull-right more"><a href="javascript:;" class="Z_shop_set">店铺管理</a></small>
        </if>
      </h4>
    </div>
    
    <notempty name="lists">
      <div class="item-list clearfix" id="Z_load_itemlist">
        <include file="Item/itemList"/>
      </div>
    <else/>
      <p class="list-empty">
        暂无商品！<br>
        <a href="{:U('Item/search')}" class="btn btn-positive">去看看别的</a>
      </p>
    </notempty>
  </div>
  
  <div id="Z_choose_menu">
    <div class="modal-select">
      <ul>
        <li><a href="{:U('Shops/item')}">商品管理</a></li>
        <li><a href="{:U('Shops/manage')}">店铺设置</a></li>
      </ul>
    </div>
  </div>
  
</block>
<block name="footer"></block>
<block name="script">
  <script type="text/javascript">
  var common;
    seajs.use(['index', 'common', 'wechat'], function(index, common, wechat){
      var url = window.location.href;
      common.loadmore(url);
      wechat.init();
      //隐藏底部空隙
      $('.Z_shop_set').click(function(){
        $.ui.select('#Z_choose_menu');
      });
      $('.content').css('paddingBottom', 0);
      /*APP分享分销店铺*/
      $('#appShare').on('click',function(){
        var id = $(this).data('uid');
        var u = navigator.userAgent;
        var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1 || u.indexOf('Linux') > -1; //android终端
        var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
        var client;
        if(isAndroid){
            client = 'andrion';
        }
        if(isiOS){
            client = 'ios';
        }
        var url = window.location.href;
        $.post($.U('Api/getShareParameters'), 'id='+id+'&url='+url+'&client='+client, function(res){
            
            if(isAndroid){
                //安卓调用分享
                window.control.appShareByAndroid(res);
            }
            if(isiOS){
                //ios调用分享
                window.webkit.messageHandlers.appShareByIos.postMessage(res);
            }
        });
      });
    });
  </script>
</block>